
package com.avocado.base.entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.TableGenerator;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;


/**
 *
 * @author wenfeng.xu
 *2011-4-10下午01:24:21
 */
@Entity
@Table(name="AVO_ORGANIZATION")
@JsonAutoDetect
@JsonIgnoreProperties(value={"users","handler","hibernateLazyInitializer"})
@Data
public class Organization implements Serializable {
	
	private static final long serialVersionUID = 4953857671795115260L;
	
	@Id@Column(name="ID",nullable=false)
	@GeneratedValue(strategy = GenerationType.TABLE,generator="id_gen")
    @TableGenerator(name = "id_gen",pkColumnValue="ORGANIZATION_ID",table="AVO_ID_GENERATOR", pkColumnName="GEN_NAME",valueColumnName="GEN_VALUE",allocationSize=1)
	private Long id;
	//中文名
	@Column(name="NAME",nullable=false,length=200)
	private String name;

	//父节点点ID
	@Column(name="PARENT_ID",nullable=false)
	private Long parentId=0L;

	//排序
	@Column(name="SORT_ORDER",nullable=false)
	private Integer sortOrder=0;
	
	
	@Column(name="CATEGORY")
	private String category;
	
	
	@Column(name="CODE",nullable=false,unique=true)
	private String code;//代码

	@Column(name="ADDRESS")
	private String address;//地址
	
	@Column(name="TELEPHONE")
	private String telephone;//电话
	
	
	@Column(name="EMAIL")
	private String email;//邮箱
	
	
	@Column(name="CONTACT_PERSON")
	private String contactPerson;//联系人


	@Temporal(TemporalType.TIMESTAMP)@Column(nullable=false,name="CREATE_TIME")
	private Date createTime=new Date();
	
	
	@Temporal(TemporalType.TIMESTAMP)@Column(nullable=false,name="UPDATE_TIME")
	private Date updateTime=new Date();

	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + (int) (id ^ (id >>> 32));
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj){
			return true;
		}
		if (obj == null){
			return false;
		}
		if (getClass() != obj.getClass()){
			return false;
		}
		Organization other = (Organization) obj;
		if (!id.equals(other.id)){
			return false;
		}
		return true;
	}

	public Organization() {
		super();
	}
	


}
